var orderDetail = JSON.parse(sessionStorage.getItem("orderDetailall"));
window.parent.isIngMaintain = false;
var dataDifferentiation=orderDetail.historyOrder//数据区分（新数据旧数据）
/*表格渲染*/
var dataSource = new Array();
//table的数据源
var table; //table对象
var rejectSomeArray = {}; //拒收列表对象
var changeAddress = false;//默认修改地址
var setAddress = {
    province: '',
    provinceCode: '',
    city: '',
    cityCode: '',
    area: '',
    areaCode: '',
    town: '',
    townCode: '',
    detailAddress: ''
};//地址信息

var originAddress = true;
var isIng = false;

dataSource = [];
orderList(orderDetail)
//数组删除某个元素
Array.prototype.indexOf = function (val) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] == val) return i;
    }
    return -1;
};
Array.prototype.remove = function (val) {
    var index = this.indexOf(val);
    if (index > -1) {
        this.splice(index, 1);
    }
};

//全部维修
function repairAll() {
    $("#datatable").show()
    $("#datatableee").hide()
    $(".jiansuo").val("")
    orderList(orderDetail)

    function orderList(data) {
        var mmmmm = ""
        var handStr = '';
        var hdStr = '';
        var hdStrdf = ""
        var hdStrdfuu = ""
        var hdSdfuu = ""
        var warehouses = JSON.parse(sessionStorage.getItem("warehouses"))
        //满减金额商品
        if (data.fullAmountReduceOrderItemsMap != "" && data.fullAmountReduceOrderItemsMap != null) {
            var arr = data.fullAmountReduceOrderItemsMap
            $.each(arr, function (index, i) {
                //算出该活动的所有商品小计和优惠值
                let countMoney = 0;
                let promotionMoney = 0;
                $.each(arr[index], function (k, v) {
                    promotionMoney = Number(promotionMoney) + Number(v.promotion_value);
                    countMoney = Number(countMoney) + Number((v.sale_price * v.buyyer_count).toFixed(2));
                })

                let ruleStr = '<tr><td colspan="11"><div>' +
                    '<span style="float: left;">' + arr[index][0].activity_rule + '</span>' +
                    '<div style="float: right"><span style="float: left;">￥' + (countMoney).toFixed(2) + '</span><br>' +
                    '<span style="float: left;">减：' + (promotionMoney).toFixed(2) + '</span></div>' +
                    '</div></td></tr>';
                mmmmm += ruleStr;

                $.each(arr[index], function (k, v) {
                        var ss = ""
                        $.each(warehouses.data, function (k, s) {
                            if (data.orderBase.parent_warehouse_id == s.warehouseCode) {
                                ss = s.warehouseName
                            }
                        })
                        mmmmm += '<tr class="biaoge1">' +
                            '<td class="biaoge1-1"><div onclick="goToGoodsDetail()" style="cursor:pointer;"><div style="float:' +
                            ' left;width:180px;padding-top:' +
                            ' 20px;margin-left: 10px;"><img style="float:left;height:55px;width:55px" name="" src="' + v.product_pic + '" alt=""><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                            '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                            '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.can_returned_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span><input type="text" class="input-text mr-5" number="' + v.receive_count + '" oninput="creatArray(this,\'some\')" value="' + v.can_maintain_count + '" style="width: 100px" placeholder="" id="" name=""><span style="display: none">' + v.sku_id + '</span></span>' + v.unit_name + '</td>' +
                            '</tr>';

                    }
                )


            })
        }
        //数量商品
        if (data.fullQuantityReduceOrderItemsMap != "" && data.fullQuantityReduceOrderItemsMap != null) {
            var arr = data.fullQuantityReduceOrderItemsMap
            $.each(arr, function (index, i) {
                //算出该活动的所有商品小计和优惠值
                let countMoney = 0;
                let promotionMoney = 0;
                $.each(arr[index], function (k, v) {
                    promotionMoney = Number(promotionMoney) + Number(v.promotion_value);
                    countMoney = Number(countMoney) + Number((v.sale_price * v.buyyer_count).toFixed(2));
                })

                let ruleStre = '<tr><td colspan="11"><div>' +
                    '<span style="float: left;">' + arr[index][0].activity_rule + '</span>' +
                    '<div style="float: right"><span style="float: left;">￥' + countMoney + '</span><br>' +
                    '<span style="float: left;">减：' + promotionMoney + '</span></div>' +
                    '</div></td></tr>';
                mmmmm += ruleStre;

                $.each(arr[index], function (k, v) {
                        var ss = ""
                        $.each(warehouses.data, function (k, s) {
                            if (data.orderBase.parent_warehouse_id == s.warehouseCode) {
                                ss = s.warehouseName
                            }
                        })
                        mmmmm += '<tr class="biaoge1">' +
                            '<td class="biaoge1-1"><div onclick="goToGoodsDetail()" style="cursor:pointer;"><div style="float:' +
                            ' left;width:180px;padding-top:' +
                            ' 20px;margin-left: 10px;"><img style="float:left;height:55px;width:55px" name="" src="' + v.product_pic + '" alt=""><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                            '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                            '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span id="create_time">' + v.can_returned_count + '' + v.unit_name + '</span></td>' +
                            '<td class="biaoge1-3"><span><input type="text" class="input-text mr-5" number="' + v.receive_count + '" oninput="creatArray(this,\'some\')" value="' + v.can_maintain_count + '" style="width: 100px" placeholder="" id="" name=""><span style="display: none">' + v.sku_id + '</span></span>' + v.unit_name + '</td>' +
                            '</tr>';

                    }
                )


            })
        }
        //特价商品
        if (data.specialPriceOrderItemsList != "" && data.specialPriceOrderItemsList != null) {
            var arr = data.specialPriceOrderItemsList

            //算出该活动的所有商品小计和优惠值
            let ii = ""
            let ruleStret = '<tr><td colspan="11"><div>' +
                '<span style="float: left;">' + ii + '</span>' +
                /*'<div style="float: right"><span style="float: left;">￥'+countMoney+'</span><br>' +
                '<span style="float: left;">减：'+promotionMoney+'</span></div>' +*/
                '</div></td></tr>';
            mmmmm += ruleStret;

            $.each(arr, function (k, v) {
                    var ss = ""
                    $.each(warehouses.data, function (k, s) {
                        if (data.orderBase.parent_warehouse_id == s.warehouseCode) {
                            ss = s.warehouseName
                        }
                    })

                    mmmmm += '<tr class="biaoge1">' +
                        '<td class="biaoge1-1"><div onclick="goToGoodsDetail()" style="cursor:pointer;"><div style="float:' +
                        ' left;width:180px;padding-top:' +
                        ' 20px;margin-left: 10px;"><img style="float:left;height:55px;width:55px" name="" src="' + v.product_pic + '" alt=""><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                        '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                        '<td class="biaoge1-2"><input style="width: 32px;background-color: yellow;" value="特价" readonly="readonly"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.can_returned_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span><input type="text" class="input-text mr-5" number="' + v.receive_count + '" oninput="creatArray(this,\'some\')" value="' + v.can_maintain_count + '" style="width: 100px" placeholder="" id="" name=""><span style="display: none">' + v.sku_id + '</span></span>' + v.unit_name + '</td>' +
                        '</tr>';

                }
            )


        }

        if (data.normalPriceOrderItemsList != "" && data.normalPriceOrderItemsList != null) {
            var arr = data.normalPriceOrderItemsList

            //算出该活动的所有商品小计和优惠值
            let ii = ""
            let ruleStret = '<tr><td colspan="11"><div>' +
                '<span style="float: left;">' + ii + '</span>' +
                /*'<div style="float: right"><span style="float: left;">￥'+countMoney+'</span><br>' +
                '<span style="float: left;">减：'+promotionMoney+'</span></div>' +*/
                '</div></td></tr>';
            mmmmm += ruleStret;

            $.each(arr, function (k, v) {
                    var ss = ""
                    $.each(warehouses.data, function (k, s) {
                        if (data.orderBase.parent_warehouse_id == s.warehouseCode) {
                            ss = s.warehouseName
                        }
                    })


                    mmmmm += '<tr class="biaoge1">' +
                        '<td class="biaoge1-1"><div onclick="goToGoodsDetail()" style="cursor:pointer;"><div style="float:' +
                        ' left;width:180px;padding-top:' +
                        ' 20px;margin-left: 10px;"><img style="float:left;height:55px;width:55px" name="" src="' + v.product_pic + '" alt=""><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                        '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.can_returned_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span><input type="text" class="input-text mr-5" number="' + v.receive_count + '" oninput="creatArray(this,\'some\')" value="' + v.can_maintain_count + '" style="width: 100px" placeholder="" id="" name=""><span style="display: none">' + v.sku_id + '</span></span>' + v.unit_name + '</td>' +
                        '</tr>';

                }
            )


        }
        $("#datatable").find("tbody").empty().append($(mmmmm));
        /*$("#datatable").find("tbody").empty().append($(hdStrdf));
        $("#datatable").find("tbody").empty().append($(hdStrdfuu));
        $("#datatable").find("tbody").empty().append($(hdSdfuu));*/


    }

    for (var i = 0; i < orderDetail.listOrderItems.length; i++) {
        rejectSomeArray[orderDetail.listOrderItems[i].sku_id] = {
            sku_id: orderDetail.listOrderItems[i].sku_id,
            maintain_count: orderDetail.listOrderItems[i].can_maintain_count,
        }
    }
}


/*function addBtn() {
    $("#fileUp").trigger('click');
}
var formData = new FormData();
//添加图片，返显
var imgKey =0;
var deleteList = [];
function putDataToPage(e,can) {
    console.log($("#intro").val());
    for(var i = 0; i < e.target.files.length; i++) {
        var file = e.target.files.item(i);
        if(!(/^image\/.*$/i.test(file.type))) {
            continue; //不是图片 就跳出这一次循环
        }
        //实例化FileReader API
        var freader = new FileReader();
        freader.readAsDataURL(file);
        freader.onload = function(e) {
            $('#imgs').append('<img width="50" height="50" src="'+e.target.result+'" id="'+imgKey+'"class="mr-10">' +
                ' <a onclick="deleteSelect(this)" id="'+imgKey+'" class="mr-20">删除</a>');
            // $("#myImg").attr("src", e.target.result);
            getupfilerul(can,e)
        }
    }
    formData.append('file', $("#fileUp")[0].files[0]);
    imgKey++;
}
function getupfilerul(can,e){
    console.log(can)
    console.log(can.parentElement);
    console.log($("#fileUp1").val)
    var formData = new FormData();
    formData.append('file',$(can)[0].files[0]);
    // formData.append('file',$("#fileUp").files);
    console.log($(can)[0].files[0])
    console.log(formData)
    $.ajax({
        url: root.inter.imgUpload,
        // url:'http://192.168.65.115:8080/contract/approval/imgNewUpload.jhtml',
        cache: false,  //禁用缓存
        type: "POST",
        // 告诉jQuery不要去处理发送的数据
        processData : false,
        // 告诉jQuery不要去设置Content-Type请求头
        contentType : false,
        data: formData,
        success: function (data) {
            proofList.push(data.imginfo.image_path);
        }
    })
}

//删除图片
function deleteSelect(e) {
    var img = e.previousElementSibling;
    // console.log(img);
    e.remove();
    img.remove();
    var src = e.id;
    deleteList.push(src);
    console.log(src);
}*/

//formdata上传图片公用方法
//触发事件
function addBtn(cen) {
    $("#filesUp").trigger('click');
}

var proofList = [];//初始化图片数组
var formData = new FormData();

// 提交上传图片
function getupfilerul(e) {
    console.log(formData)
    $.ajax({
        url: root.inter.imgUpload,
        cache: false,  //禁用缓存
        type: "POST",
        // 告诉jQuery不要去处理发送的数据
        processData: false,
        // 告诉jQuery不要去设置Content-Type请求头
        contentType: false,
        data: formData,
        success: function (data) {
            if (data.errorCode != 0) {
                $("#addImgs").hide();
                layer.msg("上传成功", {icon: 6, time: 1000});
                for (var i = 0; i < data.length; i++) {
                    proofList.push(data[i].fullPath);
                }
                console.log(proofList)
            } else {
                layer.msg(data.errorInfo, {icon: 5, time: 1000});
            }
            console.log(data)
        }
    })
}

// 上传图片返现
function putDataToPage(e) {
    // console.log($("#intro").val())
    if (e.target.files.length > 20) {
        layer.msg("最多添加20张图片", {icon: 6, time: 1000});

        return false;
    }

    for (var i = 0; i < e.target.files.length; i++) {
        var file = e.target.files.item(i);
        if (!(/^image\/.*$/i.test(file.type))) {
            continue; //不是图片 就跳出这一次循环
        }
        //实例化FileReader API
        var freader = new FileReader();
        freader.readAsDataURL(file);
        freader.onload = function (e) {
            $(".ceshi").append("<div><img class='myImg' width='50' height='50' style='margin-left: 10px' src='" + e.target.result + "'/></div>");
        }
    }
    for (var j = 0; j < $("#filesUp")[0].files.length; j++) {
        formData.append('file', $("#filesUp")[0].files[j]);
    }
    console.log(formData)
    $.ajax({
        url: root.inter.imgUpload,
        cache: false,  //禁用缓存
        type: "POST",
        // 告诉jQuery不要去处理发送的数据
        processData: false,
        // 告诉jQuery不要去设置Content-Type请求头
        contentType: false,
        data: formData,
        success: function (data) {
            if (data.errorCode != 0) {
                $("#addImgs").hide();
                layer.msg("上传成功", {icon: 6, time: 1000});
                for (var i = 0; i < data.length; i++) {
                    proofList.push(data[i].fullPath);
                }
                console.log(proofList)
            } else {
                layer.msg(data.errorInfo, {icon: 5, time: 1000});
            }
            console.log(data)
        }
    })
    $("#addPicBtn").hide();
    $("#deletBtn").show();
    $("#addImgs").show();
}

//删除图片
function deleteFiles() {
    formData = new FormData();
    $("#addImgs").hide();//隐藏上传按钮
    $(".ceshi").empty();
    $("#addPicBtn").show();
    $("#deletBtn").hide();
    proofList = [];
    /*清空input file文件*/
    var file = document.getElementById("filesUp");
    // for IE, Opera, Safari, Chrome
    if (file.outerHTML) {
        file.outerHTML = file.outerHTML;
    } else { // FF(包括3.5)
        file.value = "";
    }
}

function cancle() {
    var index = parent.layer.getFrameIndex(window.name);
    parent.layer.close(index);
}

function orderList(data) {
    $("#datatable").hide()
    $("#datatableee").show()
    var kkkkkl = ""
    var handStr = '';
    var hdStr = '';
    var hdStrdf = ""
    var hdStrdfuu = ""
    var hdSdfuu = ""
    var warehouses = JSON.parse(sessionStorage.getItem("warehouses"))
    //满减金额商品
    if (data.fullAmountReduceOrderItemsMap != "" && data.fullAmountReduceOrderItemsMap != null) {
        var arr = data.fullAmountReduceOrderItemsMap
        $.each(arr, function (index, i) {
            //算出该活动的所有商品小计和优惠值
            let countMoney = 0;
            let promotionMoney = 0;
            $.each(arr[index], function (k, v) {
                promotionMoney = Number(promotionMoney) + Number(v.promotion_value);
                countMoney = Number(countMoney) + Number((v.sale_price * v.buyyer_count).toFixed(2));
            })

            let ruleStr = '<tr><td colspan="11"><div>' +
                '<span style="float: left;">' + arr[index][0].activity_rule + '</span>' +
                '<div style="float: right"><span style="float: left;">￥' + (countMoney).toFixed(2) + '</span><br>' +
                '<span style="float: left;">减：' + (promotionMoney).toFixed(2) + '</span></div>' +
                '</div></td></tr>';
            kkkkkl += ruleStr;

            $.each(arr[index], function (k, v) {
                    var ss = ""
                    $.each(warehouses.data, function (k, s) {
                        if (data.orderBase.parent_warehouse_id == s.warehouseCode) {
                            ss = s.warehouseName
                        }
                    })

                    kkkkkl += '<tr class="biaoge1">' +
                        '<td class="biaoge1-1"><div onclick="goToGoodsDetail()" style="cursor:pointer;"><div style="float:' +
                        ' left;width:180px;padding-top:' +
                        ' 20px;margin-left: 10px;"><img style="float:left;height:55px;width:55px" name="" src="' + v.product_pic + '" alt=""><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                        '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.can_returned_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span><input type="text" class="input-text mr-5" number="' + v.receive_count + '" oninput="creatArray(this,\'some\')" value="" style="width: 100px" placeholder="" id="" name=""><span style="display: none">' + v.sku_id + '</span></span>' + v.unit_name + '</td>' +
                        '</tr>';

                }
            )


        })
    }
    //数量商品
    if (data.fullQuantityReduceOrderItemsMap != "" && data.fullQuantityReduceOrderItemsMap != null) {
        var arr = data.fullQuantityReduceOrderItemsMap
        $.each(arr, function (index, i) {
            //算出该活动的所有商品小计和优惠值
            let countMoney = 0;
            let promotionMoney = 0;
            $.each(arr[index], function (k, v) {
                promotionMoney = Number(promotionMoney) + Number(v.promotion_value);
                countMoney = Number(countMoney) + Number((v.sale_price * v.buyyer_count).toFixed(2));
            })

            let ruleStre = '<tr><td colspan="11"><div>' +
                '<span style="float: left;">' + arr[index][0].activity_rule + '</span>' +
                '<div style="float: right"><span style="float: left;">￥' + countMoney + '</span><br>' +
                '<span style="float: left;">减：' + promotionMoney + '</span></div>' +
                '</div></td></tr>';
            kkkkkl += ruleStre;

            $.each(arr[index], function (k, v) {
                    var ss = ""
                    $.each(warehouses.data, function (k, s) {
                        if (data.orderBase.parent_warehouse_id == s.warehouseCode) {
                            ss = s.warehouseName
                        }
                    })


                    kkkkkl += '<tr class="biaoge1">' +
                        '<td class="biaoge1-1"><div onclick="goToGoodsDetail()" style="cursor:pointer;"><div style="float:' +
                        ' left;width:180px;padding-top:' +
                        ' 20px;margin-left: 10px;"><img style="float:left;height:55px;width:55px" name="" src="' + v.product_pic + '" alt=""><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                        '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span id="create_time">' + v.can_returned_count + '' + v.unit_name + '</span></td>' +
                        '<td class="biaoge1-3"><span><input type="text" class="input-text mr-5" number="' + v.receive_count + '" oninput="creatArray(this,\'some\')" value="" style="width: 100px" placeholder="" id="" name=""><span style="display: none">' + v.sku_id + '</span></span>' + v.unit_name + '</td>' +
                        '</tr>';

                }
            )


        })
    }
    //特价商品
    if (data.specialPriceOrderItemsList != "" && data.specialPriceOrderItemsList != null) {
        var arr = data.specialPriceOrderItemsList

        //算出该活动的所有商品小计和优惠值
        let ii = ""
        let ruleStret = '<tr><td colspan="11"><div>' +
            '<span style="float: left;">' + ii + '</span>' +
            /*'<div style="float: right"><span style="float: left;">￥'+countMoney+'</span><br>' +
            '<span style="float: left;">减：'+promotionMoney+'</span></div>' +*/
            '</div></td></tr>';
        kkkkkl += ruleStret;

        $.each(arr, function (k, v) {
                var ss = ""
                $.each(warehouses.data, function (k, s) {
                    if (data.orderBase.parent_warehouse_id == s.warehouseCode) {
                        ss = s.warehouseName
                    }
                })

                kkkkkl += '<tr class="biaoge1">' +
                    '<td class="biaoge1-1"><div onclick="goToGoodsDetail()" style="cursor:pointer;"><div style="float:' +
                    ' left;width:180px;padding-top:' +
                    ' 20px;margin-left: 10px;"><img style="float:left;height:55px;width:55px" name="" src="' + v.product_pic + '" alt=""><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                    '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                    '<td class="biaoge1-2"><input style="width: 32px;background-color: yellow;" value="特价" readonly="readonly"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                    '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                    '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                    '<td class="biaoge1-3"><span id="create_time">' + v.can_returned_count + '' + v.unit_name + '</span></td>' +
                    '<td class="biaoge1-3"><span><input type="text" class="input-text mr-5" number="' + v.receive_count + '" oninput="creatArray(this,\'some\')" value="" style="width: 100px" placeholder="" id="" name=""><span style="display: none">' + v.sku_id + '</span></span>' + v.unit_name + '</td>' +
                    '</tr>';

            }
        )


    }

    if (data.normalPriceOrderItemsList != "" && data.normalPriceOrderItemsList != null) {
        var arr = data.normalPriceOrderItemsList

        //算出该活动的所有商品小计和优惠值
        let ii = ""
        let ruleStret = '<tr><td colspan="11"><div>' +
            '<span style="float: left;">' + ii + '</span>' +
            /*'<div style="float: right"><span style="float: left;">￥'+countMoney+'</span><br>' +
            '<span style="float: left;">减：'+promotionMoney+'</span></div>' +*/
            '</div></td></tr>';
        kkkkkl += ruleStret;

        $.each(arr, function (k, v) {
                var ss = ""
                $.each(warehouses.data, function (k, s) {
                    if (data.orderBase.parent_warehouse_id == s.warehouseCode) {
                        ss = s.warehouseName
                    }
                })

                kkkkkl += '<tr class="biaoge1">' +
                    '<td class="biaoge1-1"><div onclick="goToGoodsDetail()" style="cursor:pointer;"><div style="float:' +
                    ' left;width:180px;padding-top:' +
                    ' 20px;margin-left: 10px;"><img style="float:left;height:55px;width:55px" name="" src="' + v.product_pic + '" alt=""><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                    '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                    '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                    '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                    '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                    '<td class="biaoge1-3"><span id="create_time">' + v.can_returned_count + '' + v.unit_name + '</span></td>' +
                    '<td class="biaoge1-3"><span><input type="text" class="input-text mr-5" number="' + v.receive_count + '" oninput="creatArray(this,\'some\')" value="" style="width: 100px" placeholder="" id="" name=""><span style="display: none">' + v.sku_id + '</span></span>' + v.unit_name + '</td>' +
                    '</tr>';

            }
        )


    }
    $("#datatableee").find("tbody").empty().append($(kkkkkl));
    /* $("#datatableee").find("tbody").empty().append($(hdStrdf));
     $("#datatableee").find("tbody").empty().append($(hdStrdfuu));
     $("#datatableee").find("tbody").empty().append($(hdSdfuu));*/
    setAddress.province = orderDetail.orderExt.receiver_province_name;
    setAddress.provinceCode = orderDetail.orderExt.receiver_province;
    setAddress.city = orderDetail.orderExt.receiver_city_name;
    setAddress.cityCode = orderDetail.orderExt.receiver_city;
    setAddress.area = orderDetail.orderExt.receiver_area_name;
    setAddress.areaCode = orderDetail.orderExt.receiver_area;
    setAddress.town = orderDetail.orderExt.receiver_town_name;
    setAddress.townCode = orderDetail.orderExt.receiver_town;
    setAddress.detailAddress = orderDetail.orderExt.receiver_detail_address;
    console.log(setAddress);
    if(dataDifferentiation){
    $('#getGoodsAddress').html('');
    /*originAddress = false;*/
    
    }else{
    $('#getGoodsAddress').html(orderDetail.orderExt.receiver_province_name + ' ' + orderDetail.orderExt.receiver_city_name + ' ' + orderDetail.orderExt.receiver_area_name + ' ' + orderDetail.orderExt.receiver_town_name + ' ' + orderDetail.orderExt.receiver_detail_address);
    
    }
    $('#received_name').val(orderDetail.orderExt.received_name);
    $('#received_telephone').val(orderDetail.orderExt.received_phone)
}

function checkInput(number, e) {
    var value = $(e).val();
    var reg = /^-?\d*$/;
    // 为空
    if (value == null || value == "") {
        showErrorMsg(e, "不能为空，请输入");
    }
    // 非数字
    if (reg.test(value) == false) {
        showErrorMsg(e, "格式错误，请重新输入");
        $(e).val(reg.match(value));
    }
    value = parseInt(value);
    number = parseInt(number);
    if (value == 0 || value < 0) {
        showErrorMsg(e, "维修数量至少为1！");
    }
    // 大于购买数量
    console.log(number)
    if (value > number) {
        showErrorMsg(e, "维修数量不能大于可维修数量！");
        $(e).val(number);// 默认数量
        // 为0或者负数
    } else {
        return true;
    }
    return false;
}

function showErrorMsg(e, msg) {
    // 清空非法数据
    $(e).val("");
    $.Huimodalalert(msg, 2000);
}

var listOrderMaintainItems = [];

function creatArray(val, someOrAll) {
    console.log(val)
    var numbers = $(val).parent().parent().prev().children().text()
    console.log(numbers)
    var number = numbers.replace(/[^0-9.]/g, "")
    console.log(number)
    if (checkInput(number, val) == false) {
        return;
    }
    if (val.value != "" || val.value != 0 || someOrAll == "some") {
        console.log("val == " + val.value);
        rejectSomeArray[val.nextElementSibling.innerHTML] = {
            sku_id: val.nextElementSibling.innerHTML,
            maintain_count: val.value,
        }
    } else if (val.value != "" || someOrAll == "all") {
        rejectSomeArray[val.nextElementSibling.innerHTML].maintain_count = val.value;
    }


}



function repairSubmit() {
    if (isIng) {
        layer.msg('请求已提交，请勿重复点击！');
        return false;
    }
    isIng = true;
    for (var key in rejectSomeArray) {
        if (rejectSomeArray[key].maintain_count != "") {
            listOrderMaintainItems.push(rejectSomeArray[key]);
        }
        // console.log("key:" + JSON.stringify(rejectSomeArray[key]));
    }
    console.log(listOrderMaintainItems);
    var getaddress = '';
    // for(var i in deleteList){
    //     proofList[deleteList[i]-1]='';
    // }
    // proofList.remove('');
    console.log(proofList);
    var provinceVal = $('#pin_list1').val();
    var cityVal = $('#pin_list2').val();
    var areaVal = $('#pin_list3').val();
    var townVal = $('#pin_list4').val();
    var options = document.getElementsByClassName('options');
    var province = '';
    var city = '';
    var area = '';
    var town = '';
    for (var i in options) {
        if (options[i].value == provinceVal) {
            province = options[i].innerHTML;
        }
        if (options[i].value == cityVal) {
            city = options[i].innerHTML;
        }
        if (options[i].value == areaVal) {
            area = options[i].innerHTML;
        }
        if (options[i].value == townVal) {
            if (options[i].innerHTML == '暂无数据') {
                town = '';
            }
            else {
                town = options[i].innerHTML;
            }
        }
    }

    if ($("#maintainType").val() == 10) {
       
        var orderDetail = JSON.parse(sessionStorage.getItem("orderDetailall"));
        var provin = ""
        var city11 = ""
        var area11 = ""
        var detailaddress = ""
        var provincename = ""
        var cityname = ""
        var areaname = ""
        var returngoods = JSON.parse(sessionStorage.getItem("returngoods"))
        $.each(returngoods.data, function (k, s) {
            if (orderDetail.orderBase.warehouse_id == s.warehouseId) {
                getGoodsAddress = s.provinceName + s.cityName + s.detailAddress
                received_name = s.contactPerson
                received_telephone = s.contactPhone

                provin = s.provinceCode;
                city11 = s.cityCode;
                area11 = s.districtCode;
                provincename = s.provinceName;
                cityname = s.cityName;
                areaname = s.districtName;
                detailaddress = s.detailAddress;

            }
        })

        setAddress.provinceCode = provin;
        setAddress.province = provincename;
        setAddress.cityCode = city11;
        setAddress.city = cityname;
        setAddress.areaCode = area11;
        setAddress.area = areaname;
        setAddress.townCode = '';
        setAddress.town = '';
        setAddress.detailAddress = detailaddress;

        
    }else {
        if (changeAddress) {
            setAddress.provinceCode = $('#pin_list1').val();
            setAddress.province = province;
            setAddress.cityCode = $('#pin_list2').val();
            setAddress.city = city;
            setAddress.areaCode = $('#pin_list3').val();
            setAddress.area = area;
            setAddress.townCode = $('#pin_list4').val();
            setAddress.town = town;
            setAddress.detailAddress = $('#detailAddress').val();
        }
        else {
            var orderDetail = JSON.parse(sessionStorage.getItem("orderDetailall"));
            if(originAddress==true){
                setAddress.province = orderDetail.orderExt.receiver_province_name;
                setAddress.provinceCode = orderDetail.orderExt.receiver_province;
                setAddress.city = orderDetail.orderExt.receiver_city_name;
                setAddress.cityCode = orderDetail.orderExt.receiver_city;
                setAddress.area = orderDetail.orderExt.receiver_area_name;
                setAddress.areaCode = orderDetail.orderExt.receiver_area;
                setAddress.town = orderDetail.orderExt.receiver_town_name;
                setAddress.townCode = orderDetail.orderExt.receiver_town;
                setAddress.detailAddress = orderDetail.orderExt.receiver_detail_address;
            }else {

                if($('#getGoodsAddress').html() == ''){
                    layer.msg('请选择地址！');
                    isIng = false;
                    return false;
                }

                setAddress.provinceCode = $('#pin_list1').val();
                setAddress.province = $("#pin_list1").find("option:selected").html();
                setAddress.cityCode = $('#pin_list2').val();
                setAddress.city = $("#pin_list2").find("option:selected").html();
                setAddress.areaCode = $('#pin_list3').val();
                setAddress.area = $("#pin_list3").find("option:selected").html();
                setAddress.townCode = $('#pin_list4').val();
                setAddress.town = $("#pin_list3").find("option:selected").html();
                setAddress.detailAddress = $('#detailAddress').val();
            }



        }
    }
    $.ajax({
        contentType: "application/json",
        type: "POST",
        url: root.orderInter.order_maintain,
        cache: false, //禁用缓存
        dataType: "json",
        data: JSON.stringify({
                "order_id": orderDetail.orderBase.order_id,
                "maintain_reason": $("#maintainReason").val(),
                "maintain_desc": $("#returnRemark").val(),
                "maintain_type": $("#maintainType").val(),
                "take_goods_type": $("#maintainType").val(),
                "province": setAddress.provinceCode,
                "province_name": setAddress.province,
                "city": setAddress.cityCode,
                "city_name": setAddress.city,
                "area": setAddress.areaCode,
                "area_name": setAddress.area,
                "town": setAddress.townCode,
                "town_name": setAddress.town,
                "detail_address": setAddress.detailAddress,
                "received_name": $("#received_name").val(),
                "received_telephone": $("#received_telephone").val(),
                "maintain_role": 20,
                "operate_userid": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                "operate_username": JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.username,
                "listOrderRefundMaintainItems": listOrderMaintainItems,
                "proofList": proofList
            }
        ),
        success: function (result) {
            console.log(result);
            if (result.code == "0") {
                $.Huimodalalert('提交成功！', 1000);
                setTimeout(function () {
                    var index = parent.location.reload();
                    parent.layer.close(index)
                }, 1000)
            } else {
                isIng = false;
                layer.msg(result.message, {icon: 5, time: 1000});
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            isIng = false;
        }
    });
}

//取货地址
// 商家上门 客户邮寄逻辑
function discount() {
    $("#getGoodsType").change(function (event) {
        var fanx = $(this).find("option:selected");
        if (fanx.val() == 10) {
            // 商家上门
            var orderDetail = JSON.parse(sessionStorage.getItem("orderDetailall"));
            $('#goods_place_box').show();
            $('#getGoodsAddress').html(orderDetail.orderExt.receiver_province_name + orderDetail.orderExt.receiver_city_name + orderDetail.orderExt.receiver_area_name + orderDetail.orderExt.receiver_detail_address);
            $('#modify').show();
            $('#getgoosType').html("取货地址：")
            $('#received_name').attr("disabled", false).val(orderDetail.orderExt.received_name);
            $('#received_telephone').attr("disabled", false).val(orderDetail.orderExt.received_phone);

            // $("#detailAddress").val(orderDetail.orderExt.receiver_detail_address)
        } else {
            var orderDetail = JSON.parse(sessionStorage.getItem("orderDetailall"));
            // 客户邮寄
            $("#Choice_address").hide();
            $("#default_address").show()
            $('#goods_place_box').hide();
            $('#getGoodsAddress').show();
            $('#modify').hide();
            $('#getgoosType').html("邮寄地址：")
            var returngoods = JSON.parse(sessionStorage.getItem("returngoods"))
            var getGoodsAddress = ""//取货地址
            var received_name = ""//联系人
            var received_telephone = ""//联系人电话号
            $.each(returngoods.data, function (k, s) {
                if (orderDetail.orderBase.warehouse_id == s.warehouseId) {
                    getGoodsAddress = s.provinceName + s.cityName + s.detailAddress
                    received_name = s.contactPerson
                    received_telephone = s.contactPhone
                }
            })
            //取货地址
            $('#receiveGoodsAddress').val(getGoodsAddress);
            $('#getAddress').hide();
            //联系人
            $('#received_name').attr("disabled", true).val(received_name);
            $('#received_name').attr("disabled", "disabled");

            //联系人电话号
            $('#received_telephone').attr("disabled", true).val(received_telephone);
            $('#received_telephone').attr("disabled", "disabled");

        }
    });
}

// 点击修改地址 add by milu
function modifyAddress(val) {

    if (val == 1) { // 打开修改列表
        $("#default_address").hide();
        $("#Choice_address").show();
        if(dataDifferentiation==true){
            $("#detailAddress").val(orderDetail.orderExt.receiver_province_name+orderDetail.orderExt.receiver_city_name+orderDetail.orderExt.receiver_area_name+orderDetail.orderExt.receiver_town_name+orderDetail.orderExt.receiver_detail_address);
            //历史数据
        }else {
            $("#detailAddress").val(orderDetail.orderExt.receiver_detail_address);
        }

        // 初始化选择列表
        queryAddress("pin_list0")
    } else if (val == 2) { // 取消修改
        $("#default_address").show();
        $("#Choice_address").hide();
    } else if (val == 3) { // 保存修改
        if($("#pin_list1").find("option:selected").text()=="请选择"&&$("#pin_list2").find("option:selected").text()=="请选择"&&$("#pin_list3").find("option:selected").text()=="请选择"&&$("#pin_list4").find("option:selected").text()=="请选择"){
            $.Huimodalalert("请选择取货地址", 2000);
            return false
        }
        $('#getGoodsAddress').html($("#pin_list1").find("option:selected").text() + ' '
            + $("#pin_list2").find("option:selected").text() + ' '
            + $("#pin_list3").find("option:selected").text() + ' '
            + $("#pin_list4").find("option:selected").text() + ' ' +
            $("#detailAddress").val());

        $("#default_address").show();
        $("#Choice_address").hide();
        originAddress = false;
    } else {
        $.Huimodalalert("修改异常，请稍后再试", 2000);
        return;
    }
}

// 地址联动  add by milu
function queryAddress(targetId) {
    var parentCode = ""; // 上级地址ID
    var nextTarget = ""; // 下级下拉列表ID
    var selectedOption = ""; // 选中项

    if ("pin_list0" == targetId) { // 省
        parentCode = "";
        nextTarget = "pin_list1";
        if (originAddress == true) {
            selectedOption = orderDetail.orderExt.receiver_province
        } else {
            selectedOption = $("#pin_list1").val();
        }
    } else if ("pin_list1" == targetId) { // 市
        parentCode = $("#pin_list1").val();
        nextTarget = "pin_list2";
        if (originAddress == true) {
            selectedOption = orderDetail.orderExt.receiver_city
        } else {
            selectedOption = $("#pin_list2").val();
        }
    } else if ("pin_list2" == targetId) { // 县区
        parentCode = $("#pin_list2").val();
        nextTarget = "pin_list3";
        if (originAddress == true) {
            selectedOption = orderDetail.orderExt.receiver_area
        } else {
            selectedOption = $("#pin_list3").val();
        }
    } else if ("pin_list3" == targetId) { // 城镇
        parentCode = $("#pin_list3").val();
        nextTarget = "pin_list4";
        if (originAddress == true) {
            selectedOption = orderDetail.orderExt.receiver_town
        } else {
            selectedOption = $("#pin_list4").val();
        }
    } else {
        $.Huimodalalert("选择地址有误", 2000);
        return;
    }

    var user_data = {
        parentCode: parentCode
    };
    var succCallBack = function (data, status, response) {
        if (data.errorCode == "0") {
            var addressList = data.list;
            if (addressList == '') {
                var cer = '<option value=""></option>';
                $("#" + nextTarget).html(cer);
            } else {
                var cer = "";
                if (dataDifferentiation==true ) {
                    console.log(originAddress)
                    //旧数据
                    if(originAddress==true){
                        if ("pin_list0" == targetId) {
                            cer += '<option value="" selected>请选择</option>'
                            for (var i = 0; i < addressList.length; i++) {
                                cer += '<option value="' + addressList[i].code + '">' + addressList[i].name + '</option>'
                            }
                            $("#pin_list1").html(cer);
                            $("#pin_list2").html('<option value="" selected>请选择</option>');
                            $("#pin_list3").html('<option value="" selected>请选择</option>');
                            $("#pin_list4").html('<option value="" selected>请选择</option>');
                        }else if("pin_list1" == targetId){
                            cer += '<option value="" selected>请选择</option>'
                            for (var i = 0; i < addressList.length; i++) {
                                cer += '<option value="' + addressList[i].code + '">' + addressList[i].name + '</option>'
                            }
                            $("#pin_list2").html(cer);
                            $("#pin_list3").html('<option value="" selected>请选择</option>');
                            $("#pin_list4").html('<option value="" selected>请选择</option>');
                        }else if("pin_list2" == targetId){
                            cer += '<option value="" selected>请选择</option>'
                            for (var i = 0; i < addressList.length; i++) {
                                cer += '<option value="' + addressList[i].code + '">' + addressList[i].name + '</option>'
                            }
                            $("#pin_list3").html(cer);
                            $("#pin_list4").html('<option value="" selected>请选择</option>');
                        }else if("pin_list3" == targetId){
                            cer += '<option value="" selected>请选择</option>'
                            for (var i = 0; i < addressList.length; i++) {
                                cer += '<option value="' + addressList[i].code + '">' + addressList[i].name + '</option>'
                            }
                            $("#pin_list4").html(cer);
                        }
                    }else {
                        for (var i = 0; i < addressList.length; i++) {
                            if (selectedOption == addressList[i].code) {
                                cer += '<option value="' + addressList[i].code + '" selected>' + addressList[i].name + '</option>'
                            } else {
                                cer += '<option value="' + addressList[i].code + '">' + addressList[i].name + '</option>'
                            }
                        }
                        $("#" + nextTarget).html(cer);
                        if(nextTarget != "pin_list4"){
                            queryAddress(nextTarget);
                        }
                    }


                }else {
                    for (var i = 0; i < addressList.length; i++) {
                        if (selectedOption == addressList[i].code) {
                            cer += '<option value="' + addressList[i].code + '" selected>' + addressList[i].name + '</option>'
                        } else {
                            cer += '<option value="' + addressList[i].code + '">' + addressList[i].name + '</option>'
                        }
                    }
                    $("#" + nextTarget).html(cer);
                    if(nextTarget != "pin_list4"){
                        queryAddress(nextTarget);
                    }
                }
            }
        }
        // 查询子级地址信息
       /* if (nextTarget != "pin_list4") {
            queryAddress(nextTarget);
        }*/
    };
    web.doAjax(root.orderInter.order_return_address_new, 'post', user_data, succCallBack);
    if (targetId == "pin_list1") {
        $("#" + targetId + " option").each(function () {//遍历所有option
            var text = $(this).text();
            var select = $(this).select();
            console.log(select[0].selected);
            if (select[0].selected) {
                if (text == "北京" || text == "上海" || text == "天津" || text == "重庆" || text == "台湾" || text == "香港" || text == "澳门" || text == "钓鱼岛") {
                    $("#pin_list4").hide();
                } else {
                    $("#pin_list4").show();
                }

            }

        });
    }
}

//添加地址
function discountdata(val) {
    if (val == 123) {
        //初始化 省
        var special = $('#pin_list1').val()
        var user_data = {
            level: '101',
            // memberId:'10258',
        }
        var succCallBack = function (data, status, response) {
            console.log(data)
            if (data.errorCode == "1") {
                var tab_data = data.list;
                if (tab_data == '') {
                    cer += '<option value=""></option>'
                    $("#pin_list1").html(cer);
                } else {
                    var cer = ""
                    for (var i = 0; i < tab_data.length; i++) {
                        cer += '<option value="' + tab_data[i].address_id + '">' + tab_data[i].name + '</option>'
                    }
                    $("#pin_list1").html(cer);
                }
            }
        };
        web.doAjax(root.orderInter.order_return_address, 'post', user_data, succCallBack);
    } else if (val == 1) {
        //市
        var special = $('#pin_list1').val()
        var user_data = {
            level: '102',
            // memberId:'10258',
            addressIdStr: special
        }
        var succCallBack = function (data, status, response) {
            console.log(data)
            if (data.errorCode == "1") {
                var tab_data = data.list;
                if (tab_data == '') {
                    cer += '<option value=""></option>'
                    $("#pin_list2").html(cer);
                } else {
                    var cer = ""
                    for (var i = 0; i < tab_data.length; i++) {
                        cer += '<option value="' + tab_data[i].address_id + '">' + tab_data[i].name + '</option>'
                    }
                    $("#pin_list2").html(cer);
                    $("#pin_list2").val(orderDetail.orderExt.receiver_city);
                    //选择完省出现市 去记载 区 县
                    discountdata(2)
                    setTimeout(function () {
                        discountdata(3)
                    }, 100);
                }
            }
        };
        web.doAjax(root.orderInter.order_return_address, 'post', user_data, succCallBack);
    } else if (val == 2) {
        //区
        var special = $('#pin_list2').val()
        var user_data = {
            level: '103',
            // memberId:'10258',
            addressIdStr: special
        }
        var succCallBack = function (data, status, response) {
            console.log(data)
            if (data.errorCode == "1") {
                var tab_data = data.list;
                if (tab_data == '') {
                    cer += '<option value=""></option>'
                    $("#pin_list3").html(cer);
                } else {
                    var cer = ""
                    for (var i = 0; i < tab_data.length; i++) {
                        cer += '<option value="' + tab_data[i].address_id + '">' + tab_data[i].name + '</option>'
                    }
                    $("#pin_list3").html(cer);
                    $("#pin_list3").val(orderDetail.orderExt.receiver_area);
                    //选择完市出现区 去记载  县
                    discountdata(3)
                }
            }
        };
        web.doAjax(root.orderInter.order_return_address, 'post', user_data, succCallBack);
    } else if (val == 3) {
        //县
        var special = $('#pin_list3').val()
        var user_data = {
            level: '104',
            // memberId:'10258',
            addressIdStr: special
        }
        var succCallBack = function (data, status, response) {
            if (data.errorCode == "1") {
                var tab_data = data.list;
                if (tab_data == '') {
                    cer += '<option value=""></option>'
                    $("#pin_list4").html(cer);
                } else {
                    var cer = ""
                    for (var i = 0; i < tab_data.length; i++) {
                        cer += '<option value="' + tab_data[i].address_id + '">' + tab_data[i].name + '</option>'
                    }
                    $("#pin_list4").html(cer);
                    if (orderDetail.orderExt.receiver_town != 0) {
                        $("#pin_list4").val(orderDetail.orderExt.receiver_town);
                    }
                }
            }
        };
        web.doAjax(root.orderInter.order_return_address, 'post', user_data, succCallBack);
    }
}

function mainType(val) {
    var returngoods = JSON.parse(sessionStorage.getItem("returngoods"))
    console.log(val)
    if (val == 10) {
        var orderDetail = JSON.parse(sessionStorage.getItem("orderDetailall"));
        $('#receiveAddress').removeClass('hide');
        var getGoodsAddress = ""//取货地址
        var received_name = ""//联系人
        var received_telephone = ""//联系人电话号
        $.each(returngoods.data, function (k, s) {
            if (orderDetail.orderBase.warehouse_id == s.warehouseId) {
                getGoodsAddress = s.provinceName + s.cityName + s.detailAddress
                received_name = s.contactPerson
                received_telephone = s.contactPhone
            }
        })
        //取货地址
        $('#receiveGoodsAddress').val(getGoodsAddress);

        $('#getAddress').hide();
        //联系人
        $('#received_name').attr("disabled", true).val(received_name);
        $('#received_name').attr("disabled", "disabled");

        //联系人电话号
        $('#received_telephone').attr("disabled", true).val(received_telephone);

        $('#received_telephone').attr("disabled", "disabled");
    }
    else if (val == 20) {
        $('#receiveAddress').addClass('hide');
        $('#getAddress').show();
        discountdata(123);
        $('#received_name').removeAttr("disabled");
        $('#received_telephone').removeAttr("disabled");
        $('#received_name').val('');
        $('#received_telephone').val('')
    } else if (val == 30) {
        $('#receiveAddress').addClass('hide');
        $('#getAddress').show();
        discountdata(123);
        $('#received_name').removeAttr("disabled");
        $('#received_telephone').removeAttr("disabled");
        $('#received_name').val('');
        $('#received_telephone').val('')
    }
}

//检索
function retrievaldatas(obj) {
    if($("#datatableee").css("display")=="none"){
        setTimeout(function(){//因为是即时查询，需要用setTimeout进行延迟，让值写入到input内，再读取
            var storeId = document.getElementById('datatable');//获取table的id标识
            var rowsLength = storeId.rows.length;//表格总共有多少行
            var key = obj.value;//获取输入框的值
            var searchCol = 0;//要搜索的哪一列，这里是第一列，从0开始数起
            var numsall1=0
            for(var i=1;i<rowsLength;i++){//按表的行数进行循环，本例第一行是标题，所以i=1，从第二行开始筛选（从0数起）
                var searchText=$($(storeId.rows[i].cells[searchCol].children).children()[0]).find("div")
                var searchTextall=""
                for (var m=0;m<searchText.length;m++) {
                    searchTextall+=$($(searchText)[m]).html().trim()
                }
                if(searchTextall!=undefined){
                if(searchTextall.match(key)){//用match函数进行筛选，如果input的值，即变量 key的值为空，返回的是ture，
                    numsall1++;
                    storeId.rows[i].style.display='';//显示行操作，
                }else{
                    storeId.rows[i].style.display='none';//隐藏行操作
                }}
            }
            if(numsall1==0){
                $.Huimodalalert('没有检索到数据',2000);
            }
        },200);//200为延时时间
    }else {
        setTimeout(function(){//因为是即时查询，需要用setTimeout进行延迟，让值写入到input内，再读取
            var storeId = document.getElementById('datatableee');//获取table的id标识
            var rowsLength = storeId.rows.length;//表格总共有多少行
            var key = obj.value;//获取输入框的值
            var searchCol = 0;//要搜索的哪一列，这里是第一列，从0开始数起
            var numsall=0
            for(var i=1;i<rowsLength;i++){//按表的行数进行循环，本例第一行是标题，所以i=1，从第二行开始筛选（从0数起）
                var searchText=$($(storeId.rows[i].cells[searchCol].children).children()[0]).find("div")
                var searchTextall=""
                for (var m=0;m<searchText.length;m++) {
                    searchTextall+=$($(searchText)[m]).html().trim()
                }
                if(searchTextall!=undefined){
                if(searchTextall.match(key)){//用match函数进行筛选，如果input的值，即变量 key的值为空，返回的是ture，
                    numsall++;
                    storeId.rows[i].style.display='';//显示行操作，
                }else{
                    storeId.rows[i].style.display='none';//隐藏行操作
                }
                }
            }
            if(numsall==0){
                $.Huimodalalert('没有检索到数据',2000);
            }
        },200);//200为延时时间
    }


}